Skip to content

fix: prevent duplicate project applications#211

Merged
nensii21 merged 2 commits into
nensii21:mainfrom
Ayush-0918:prevent-duplicate-applications
Jul 11, 2026
Merged

fix: prevent duplicate project applications#211
nensii21 merged 2 commits into
nensii21:mainfrom
Ayush-0918:prevent-duplicate-applications

Conversation

@Ayush-0918

Copy link
Copy Markdown
Contributor

Pull Request

Summary

This pull request prevents users from submitting duplicate applications to the same project by adding backend validation before creating a new application.


Related Issue

Fixes #202


Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Performance improvement
  • Refactoring
  • UI/UX enhancement
  • Tests
  • Other

Changes Made

  • Added a backend validation to check for an existing application from the same user for the same project.
  • Returns HTTP 409 Conflict when a duplicate application is detected.
  • Preserved the existing application creation workflow for valid requests.

Screenshots (if applicable)

N/A (Backend change)


Testing

  • Tested locally
  • Existing tests pass
  • Added new tests
  • UI verified
  • Cross-browser tested (if applicable)

Additional testing notes

  • Verified the implementation compiles successfully using:
python3 -m py_compile app/services/application_service.py
  • Confirmed that the duplicate validation does not affect normal application creation.

Checklist

  • My code follows the project's coding standards.
  • I have tested my changes locally.
  • I have updated the documentation where necessary.
  • My changes do not introduce new warnings or errors.
  • I have reviewed my own code.
  • This pull request focuses on a single bug fix.
  • I have linked the related issue.

Additional Notes

This implementation adds server-side validation to prevent duplicate project applications and returns a clear 409 Conflict response when a duplicate submission is attempted, while keeping the existing application flow unchanged.

@nensii21

nensii21 commented Jul 8, 2026

Copy link
Copy Markdown
Owner

attached videos and screenshots showing what changes have been made also some CI jobs are failing update it.

@Ayush-0918

Copy link
Copy Markdown
Contributor Author

Hi! I have updated the PRs and pushed the requested fixes. I also starred the repository.

For PR #210, the latest workflows are currently awaiting maintainer approval.
For PR #211, all checks are passing except the Require Repository Star workflow, even though I've already starred the repository.
I have also attached the requested screenshots/videos. Could you please approve/re-run the workflows when you have a chance? Thank you!

@nensii21

nensii21 commented Jul 9, 2026

Copy link
Copy Markdown
Owner

where you have attached screenshots?

@Ayush-0918

Copy link
Copy Markdown
Contributor Author

Apologies, that's my mistake. I forgot to attach them. I'll upload the requested screenshots and a short demo shortly. Thanks for pointing it out!

@Ayush-0918

Copy link
Copy Markdown
Contributor Author

Hi! I tried to generate the requested screenshots and video, but I'm currently unable to reproduce the flow locally because the backend doesn't start on my current setup. Could you let me know the expected setup or the exact flow you'd like me to capture? I'll attach the screenshots and demo as soon as I can reproduce it. Thanks!

@nensii21

nensii21 commented Jul 9, 2026

Copy link
Copy Markdown
Owner

Thanks for the implementation. The duplicate application check in create_application() looks good, and returning 409 Conflict is the appropriate HTTP response.

Before this can be considered complete, there are a few things that should be addressed:

Add a database-level unique constraint on (applicant_id, project_id) to prevent race conditions. The current validation only exists at the application layer, so two concurrent requests could still create duplicate records.
Handle IntegrityError during commit() by rolling back the transaction and returning the same 409 Conflict response. This ensures the API behaves correctly even if the database constraint is triggered.
Update or add tests to verify that a second application to the same project returns 409 Conflict, as required by the acceptance criteria.

Once those changes are included, the implementation should fully satisfy the issue requirements.

@Ayush-0918

Ayush-0918 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

Hi @nensii21 I've pushed the requested changes:

Added a database-level unique constraint on (applicant_id, project_id).
Added IntegrityError handling with rollback and the same 409 Conflict response.

I also looked for the existing test infrastructure to add/update tests, but I couldn't find a project test suite (tests/, pytest, or related configuration). If there's a preferred testing setup, I'd be happy to add the requested test there.

I also noticed that one of the GitHub Actions checks is currently failing because of an invalid workflow configuration:

.github/workflows/frontend-ci.yml
Line 16, Col 5: 'defaults' is already defined

I verified that I didn't modify anything under .github, so this seems unrelated to the changes in this PR. Could you please take a look or re-run the checks once it's resolved? Thank you!

@nensii21 nensii21 merged commit b8ea33c into nensii21:main Jul 11, 2026
5 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prevent Duplicate Applications

2 participants